<template>
	<view class="tabbar market">
		<Header></Header>
		<view class="property">
			<view class="label" @click="router('/pages/home/market_list')">进入仓库</view>
			<view class="list">
				<view class="item">
					<image :src="`${baseImageUrl}/common/hot_cover1.png`"></image>
					<view class="value">{{foodstuff}}</view>
				</view>
				<view class="item">
					<image :src="`${baseImageUrl}/common/hot_cover4.png`"></image>
					<view class="value">{{music}}</view>
				</view>
				<view class="item">
					<image :src="`${baseImageUrl}/common/hot_cover2.png`"></image>
					<view class="value">{{cloth}}</view>
				</view>
				<view class="item">
					<image :src="`${baseImageUrl}/common/hot_cover5.png`"></image>
					<view class="value">{{escort}}</view>
				</view>
				<view class="item">
					<image :src="`${baseImageUrl}/common/hot_cover3.png`"></image>
					<view class="value">{{titledeed}}</view>
				</view>
				<view class="item" @click="router('/pages/market/exchange')">
					<image :src="`${baseImageUrl}/common/hot_cover3.png`"></image>
					<view class="value">{{integral}}</view>
				</view>
				<!-- <view class="item_btn">
					<view @click="router('/pages/market/give_silver')">转赠</view>
				</view> -->
			</view>
		</view>
		<view class="tabs">
			<view class="item" :class="active==1?'active':''" @click="changeActive(1)">我的藏品</view>
			<view class="item" :class="active==2?'active':''" @click="changeActive(2)">我的盲盒</view>
			<view class="item" :class="active==3?'active':''" @click="changeActive(3)">我的道具</view>
		</view>
		<scroll-view scroll-y class="scroll_view">
			<view class="list">
				<view class="item" v-for="item in list" @click="routerFiter">
					<image :src="item.product_cover" class="cover"></image>
					<view class="number">{{item.total}}份</view>
					<view class="name">{{item.product_name}}</view>
				</view>
			</view>
		</scroll-view>
		<Footer active="1"></Footer>
	</view>
</template>

<script>
	import {
		userProduct
	} from '@/request/api.js';
	import Header from "@/components/tabbar/Header.vue";
	import Footer from "@/components/tabbar/Footer.vue";
	export default {
		components: {
			Header,
			Footer
		},
		data() {
			return {
				foodstuff: 0.00,
				music: 0.00,
				cloth: 0.00,
				escort: 0.00,
				titledeed: 0.00,
				integral: 0,
				active: 1,
				list: []
			}
		},
		onLoad() {
			this.getList();
		},
		methods: {
			async getList() {
				let {
					orders,

					foodstuff,
					music,
					cloth,
					escort,
					titledeed,
					integral
				} = await userProduct({
					product_type: this.active
				});
				this.list = orders;

				this.foodstuff = foodstuff;
				this.music = music;
				this.cloth = cloth;
				this.escort = escort;
				this.titledeed = titledeed;
				this.integral = integral;
			},
			changeActive(index) {
				this.active = index;
				this.list = [];
				this.page = 1;
				this.getList();
			},
			routerFiter() {
				let url;
				if (this.active == 1) {
					url = `/pages/market/my_collection_list?type=${this.active}`
				}
				if (this.active == 2) {
					url = '/pages/market/my_blind_box_list'
				}
				if (this.active == 3) {
					url = `/pages/market/my_collection_list?type=${this.active}`
				}
				this.router(url);
			}
		}
	}
</script>
<style scoped lang="scss">
	.market {
		background: #29170D;
		height: 100vh;
		box-sizing: border-box;
		overflow: hidden;

		.property {
			width: 100%;
			height: 364rpx;
			padding: 174rpx 316rpx 0 30rpx;
			box-sizing: border-box;
			background: url(#{$baseImageUrl}/market/1.png) no-repeat;
			background-size: 100% 100%;
			position: relative;

			.label {
				width: 150rpx;
				height: 52rpx;
				line-height: 52rpx;
				text-align: center;
				color: #494338;
				font-size: 26rpx;
				font-weight: 400;
				font-family: SimSun;
				background: url(#{$baseImageUrl}/market/label.png) no-repeat;
				background-size: 100% 100%;
				position: absolute;
				right: 87rpx;
				bottom: 24rpx;
				z-index: 2;
			}

			.list {
				display: flex;
				flex-wrap: wrap;
				justify-content: space-between;

				.item {
					width: 200rpx;
					height: 30rpx;
					margin-bottom: 20rpx;
					padding-left: 20rpx;
					box-sizing: border-box;
					display: flex;
					align-items: center;
					position: relative;

					image {
						width: 50rpx;
						height: 50rpx;
						position: absolute;
						left: 0;
						top: -10rpx;
						z-index: 2;
					}

					.value {
						flex: 1;
						height: 30rpx;
						line-height: 30rpx;
						text-align: center;
						color: #FFFEFE;
						font-size: 30rpx;
						font-weight: 400;
						font-family: SimSun;
						background: #37302A;
					}
				}

				.item_btn {
					flex: 1;
					padding-left: 10rpx;
					box-sizing: border-box;

					view {
						width: 100rpx;
						height: 40rpx;
						line-height: 40rpx;
						text-align: center;
						color: #FFFEFE;
						font-size: 20rpx;
						font-weight: 400;
						font-family: SimSun;
						background: url(#{$baseImageUrl}/common/btn.png) no-repeat;
						background-size: 100% 100%;
					}

				}
			}
		}

		.tabs {
			width: 710rpx;
			height: 100rpx;
			margin: 0 auto;
			padding: 0 15rpx;
			box-sizing: border-box;
			background-color: rgba(31, 11, 5, 0.6);
			display: flex;
			justify-content: space-between;
			align-items: center;

			.item {
				width: 210rpx;
				height: 80rpx;
				line-height: 80rpx;
				text-align: center;
				color: #FFFFFF;
				font-size: 36rpx;
				font-weight: 400;
				font-family: LiSu;

				&.active {
					color: #494338;
					background: url(#{$baseImageUrl}/common/active.png) no-repeat;
					background-size: 100% 100%;
				}
			}
		}

		.scroll_view {
			height: calc(100vh - 464rpx - #{$tabbarFooterHeihgt});
			padding: 30rpx 30rpx 0;
			box-sizing: border-box;

			.list {
				display: flex;
				flex-wrap: wrap;
				justify-content: space-between;

				.item {
					width: 330rpx;
					height: 457rpx;
					margin-bottom: 20rpx;
					padding: 10rpx 12rpx;
					box-sizing: border-box;
					background: url(#{$baseImageUrl}/market/330_457.png) no-repeat;
					background-size: 100% 100%;

					.cover {
						width: 100%;
						height: 304rpx;
					}

					.number {
						width: 100%;
						height: 44rpx;
						line-height: 44rpx;
						text-align: center;
						color: #483221;
						font-size: 42rpx;
						font-weight: 400;
						font-family: SimSun;
						margin: 20rpx 0;
						background: url(#{$baseImageUrl}/market/title.png) no-repeat;
						background-size: 100% 100%;
					}

					.name {
						text-align: center;
						color: #483221;
						font-size: 32rpx;
						font-weight: 400;
						font-family: SimSun;
					}
				}
			}
		}
	}
</style>